/**
 * 指定值的几次幂
 * @param {初始} init
 * @param {几次幂} n
 */
function erdencimi(init, n) {
  let sum = 1;
  for (let i = 0; i < n; i++) {
    sum *= 2;
  }
  console.log(`${init}的${n}次幂是：${sum}`);
}
// erdencimi(2, 0);

function fibonaqie1(n) {
  let first = 1,
    second = 1,
    third;
  for (let i = 0; i < n - 2; i++) {
    third = first + second;
    first = second;
    second = third;
  }
  console.log(`斐波那契额数列第${n}个是：${third}`);
}
// fibonaqie1(6)
/**
 * 100 以内的质数
 */
function zhishu100() {
  let list = [],
    count = 0;
  // 判断质数的算法
  for (let i = 0; i < 100; i++) {
    for (let j = 1; j <= Math.sqrt(i); j++) {
      if (i % j == 0) {
        count++;
      }
    }
    if (count == 1) {
      list.push(i);
    }
    count = 0;
  }
  console.log(`100以内的质数集合是：${list}`);
}
// zhishu100();

function switchs() {
  switch (ssss) {
    case [sss > 1 && sss < 2]:
      break;
  }
}

function jc(n) {
  if (n == 1) {
    return 1;
  }
  return n * jc(n - 1);
}
// console.log("5的阶乘是：" + jc(5));

// 1 1 2 3 5 8
function fibonacciList(n) {
  let list = [1, 2];
  for (let i = 2; i < n; i++) {
    list[i] = list[i - 1] + list[i - 2];
  }
  return list;
}
// console.log("斐波那契额数列的前10项是：" + fibonacciList(10));

function fibonacci(n) {
  if (n < 0) return 0;
  if (n == 1) return 1;
  return fibonacci(n - 1) + fibonacci(n - 2);
}
// console.log("斐波那契额数列的第10项是：" + fibonacci(10));

// var arr = [1, 2, 3, 4, 5];
// var ad = arr.splice(1, 0, 3333);
// console.log(ad, arr);



// 11111111
// (function(x){
//   delete x;
//   return x;
// })(1);
